import pymysql

db = pymysql.connect(host='localhost', port=3306, user='root',
                     password='guang', database='crawler')  # 连接数据库
cursor = db.cursor()  # 获取游标


sql1 = "insert into demo_one(id,title,content) values(null,'lzh','这里是lzh的内容')"
cursor.execute(sql1)  # 执行sql语句

sql2 = "insert into demo_one(id,title,content) values(null,%s,%s)"  # 使用占位符
cursor.execute(sql2, ('lk', '这里是lk的内容'))  # 执行sql语句

db.commit()  # 提交
db.close()  # 关闭数据库连接
